package io.renren.modules.health.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.modules.health.dao.HmFoodRecordDao;
import io.renren.modules.health.dto.HmFoodRecordDTO;
import io.renren.modules.health.entity.HmFoodRecordEntity;
import io.renren.modules.health.service.HmFoodRecordService;
import cn.hutool.core.util.StrUtil;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.Map;

/**
 * 客户饮食记录
 *
 * @author  
 * @since 1.0.0 2024-04-03
 */
@Service
public class HmFoodRecordServiceImpl extends CrudServiceImpl<HmFoodRecordDao, HmFoodRecordEntity, HmFoodRecordDTO> implements HmFoodRecordService {

    @Override
    public QueryWrapper<HmFoodRecordEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");
        Long cusId = (Long)params.get("cusId");
        LocalDate recordDate = (LocalDate)params.get("recordDate");
        Integer planDayTime = (Integer)params.get("planDayTime");

        QueryWrapper<HmFoodRecordEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StrUtil.isNotBlank(id), "id", id);
        wrapper.eq(cusId != null, "cus_id", cusId);
        wrapper.eq(recordDate != null, "record_date", recordDate);
        wrapper.eq(planDayTime != null, "plan_day_time", planDayTime);

        return wrapper;
    }


}